var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
// var cors = require('cors');
// const bodyParser = require('body-parser')
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var alarmRouter = require('./routes/alarm');
var toolsRouter = require('./routes/tools');

const jwt = require('jsonwebtoken');
const signkey = 'lihanmin';

var app = express();
var http = require('http');

var server = http.createServer(app);

app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/user', usersRouter);
app.use('/alarm', alarmRouter);
app.use('/tools', toolsRouter);


server.listen('3000')